package aircraft_war;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.sql.Array;
import java.util.AbstractList;
import java.util.ArrayList;

public class HeroPlane extends BasicClass implements Award{
    int score;
    Bullet[] bullets;
    //ArrayList<Bullet> list=new ArrayList();

    int count,choose=0;
    BufferedImage[] imgs={Main.hero0,Main.hero1};
    /*public void moveTo(int x,int y){
        this.x = x - width/2;
        this.y = y - height/2;
    }*/
    @Override
    public void move() {
        count++;
        if (count%4==0){
            this.img=imgs[1];
        }
        else{
            this.img=imgs[0];
        }

    }
    public void addBloot() {
        this.blood++;
    }

    public void addFire() {
        choose+=20;
        if (this.flag==1){
            this.flag=2;
        }
        else if (this.flag==2){
            this.flag=3;
        }
    }
    int flag=1;
    public Bullet[] shoot(){

        if (flag==1){
            Bullet[] bs=new Bullet[1];
            bs[0]=new Bullet(this.x+width/2,this.y);
            return bs;
        }
        else if(flag==2){
            choose--;
            Bullet[] bs=new Bullet[2];
            bs[0]=new Bullet(this.x+width/4,this.y);
            bs[1]=new Bullet(this.x+width/4*3,this.y);
            if (choose<=0){
                flag=1;
            }
            return bs;
        }
        else {
            choose--;
            Bullet[] bs=new Bullet[3];
            bs[0]=new Bullet(this.x+width/4,this.y);
            bs[1]=new Bullet(this.x+width/2,this.y-7);
            bs[2]=new Bullet(this.x+width/4*3,this.y);
            if (choose<=20){
                flag=2;
            }
            return bs;
        }

    }
    public HeroPlane(){
        img=Main.hero0;
        score=0;
        width=img.getWidth();
        height=img.getHeight();
        blood=3;
        x=Main.WIDTH/2-img.getWidth()/2;
        /*y=-height;*/
        y=400;

    }


    @Override
    public void choice() {
        int num=(int)(Math.random()*10);
        if (num<5){
            addBloot();
        }
        else {
            addFire();
        }
    }
}
